import mongoose from 'mongoose'
import {GraphQLString} from "graphql";

const Schema = mongoose.Schema
const ObjectId = Schema.Types.ObjectId


const InfoSchema = new Schema({
  name: String,
  job: String,
  school: String,
  time: String,
  status: String,
  phone: String,
  email: String,
  meta: {
	createdAt: {
	  type: Date,
	  default: Date.now()
	},
	updatedAt: {
	  type: Date,
	  default: Date.now()
	}
  }
})

InfoSchema.pre('save', function (next) {
  if (this.isNew) {
	this.meta.createdAt = this.meta.updatedAt = Date.now()
  } else {
	this.meta.updatedAt = Date.now()
  }

  next()
})

mongoose.model('Info', InfoSchema)
